Documentation Center

Using Web Service in PHP [deprecated]

This is a short example for a PHP web service call.

Before you begin

All core functionality is available through a Web Services API, making integrations with other applications easy. Both Web Services and SOAP (Simple Object Access Protocol) are platform independent and open standards (W3C/OASIS). So, yes, PHP is capable of connecting via Web Services to a Content Manager application using SOAP.

We created a working example on January 2010 using the following prerequisites:
  • PHP 5

About this task

Presuming you have the prequisites installed:
  1. All of the functions are described and available using the Web Services Description Language (WSDL). So, if you go to http://ish.example.com/ISHWS/Application20.asmx?wsdl (where ish refers to an example server dedicated to Content Manager), you can see the description of the Application20 Class. You will definitely want to keep the WSDL handy as it is the quickest and easiest way to know what the specific input and output parameters are. A snippet of the "Login" function from the WSDL is below:
    <s:element name="Login">
      <s:complexType>
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="psApplication" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="psUserName" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="psPassword" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="psOutAuthContext" type="s:string"/>
        </s:sequence>
      </s:complexType>
    </s:element>
    <s:element name="LoginResponse">
      <s:complexType>
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="LoginResult" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="psOutAuthContext" type="s:string"/>
        </s:sequence>
      </s:complexType>
    </s:element>
    
  2. Therefore, the following PHP queries Content Manager and returns the psOutAuthContext that you can then use as an input parameter to other functions. The sample also provides for echoing the XML request/response to the screen as well so you can see the request and response. PHP to connect to Content Manager, query the WSDL and generate functions from the WSDL, send a SOAP request for the login function, and return a SOAP response:
    <?php
      $base_url = "http://ish.example.com/ISHWS";
      $client = new SoapClient($base_url."/Application20.asmx?wsdl",array(
        "trace"      => 1,
        "exceptions" => 0));
      
      $params   = array(
        'psApplication'   => "ISHCM",
        'psUserName'      => "YOUR_USER_NAME_HERE",
        'psPassword'      => "YOUR_PASSOWRD_HERE",
        );
     
      $client->login($params);
      print "<pre>\n";
      print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
      print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n\n";
      print "</pre>";
    ?>